package com.yunji.storage.context;

import com.yunji.base.cache.BaseCache;
import com.yunji.common.utils.bean.BeanUtils;
import com.yunji.storage.domain.RepairTicketDO;
import com.yunji.storage.vo.RepairTicketVO;

import java.util.ArrayList;
import java.util.List;

public class RepairTicketConvert {
    public static List<RepairTicketVO> domainToVO(List<RepairTicketDO> list) {
        List<RepairTicketVO> voList = new ArrayList<>();
        list.forEach(item -> voList.add(domainToVO(item)));
        return voList;
    }

    public static RepairTicketVO domainToVO(RepairTicketDO ticket) {
        RepairTicketVO vo = new RepairTicketVO();
        BeanUtils.clone(ticket, vo);
        vo.setBelongName(BaseCache.getBelongName(vo.getBelongId()));
        vo.setOutBelongName(BaseCache.getBelongName(vo.getOutBelongId()));
        vo.setIntoBelongName(BaseCache.getBelongName(vo.getIntoBelongId()));
        return vo;
    }
}
